package cn.uexpo.lhz.biz.impl;

import java.util.List;

import cn.uexpo.lhz.domain.vo.EquipmentTrafficVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



import cn.uexpo.lhz.biz.EquipmentTrafficBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.EquipmentTrafficMapper;
import cn.uexpo.lhz.domain.EquipmentTraffic;
import cn.uexpo.lhz.domain.EquipmentTrafficExample;

@Service
public class EquipmentTrafficBizImpl implements EquipmentTrafficBiz {

    @Autowired
    private EquipmentTrafficMapper equipmentTrafficMapper;

    @Override
    public int insert(EquipmentTraffic record) throws BOException {
        return equipmentTrafficMapper.insert(record);
    }

    @Override
    public int insertSelective(EquipmentTraffic record) throws BOException {
        return equipmentTrafficMapper.deleteByPrimaryKey(record.getId());

    }

    @Override
    public int deleteByPrimaryKey(Integer id) throws BOException {
        return equipmentTrafficMapper.deleteByPrimaryKey(id);

    }

    @Override
    public int deleteEntity(EquipmentTraffic record) throws BOException {
        return equipmentTrafficMapper.deleteByPrimaryKey(record.getId());

    }

    @Override
    public int deleteByIds(List<Integer> ids) throws BOException {
        int no = 0;
        if (null != ids) {
            for (Integer id : ids) {
                no = equipmentTrafficMapper.deleteByPrimaryKey(id);
                if (no == 0) {
                    throw new RuntimeException("删除失败。");
                }
            }
        }

        return no;
    }

    @Override
    public int delete(List<EquipmentTraffic> records) throws BOException {
        int no = 0;
        if (null != records && records.size() > 0) {
            for (EquipmentTraffic equipmentEntity : records) {
                no = equipmentTrafficMapper.deleteByPrimaryKey(equipmentEntity.getId());
                if (no == 0) {
                    throw new RuntimeException("删除失败。");
                }
            }
        }

        return no;
    }

    @Override
    public int deleteByExample(EquipmentTrafficExample example) throws BOException {
        return equipmentTrafficMapper.deleteByExample(example);

    }

    @Override
    public int updateByPrimaryKey(EquipmentTraffic record) throws BOException {
        return equipmentTrafficMapper.updateByPrimaryKey(record);

    }

    @Override
    public int updateByPrimaryKeySelective(EquipmentTraffic record) throws BOException {
        return equipmentTrafficMapper.updateByPrimaryKeySelective(record);

    }

    @Override
    public int updateByExampleSelective(EquipmentTraffic record, EquipmentTrafficExample example) throws BOException {
        return equipmentTrafficMapper.updateByExampleSelective(record, example);

    }

    @Override
    public int updateByExample(EquipmentTraffic record, EquipmentTrafficExample example) throws BOException {
        return equipmentTrafficMapper.updateByExample(record, example);

    }

    @Override
    public EquipmentTraffic selectByPrimaryKey(Integer id) throws BOException {
        return equipmentTrafficMapper.selectByPrimaryKey(id);

    }

    @Override
    public EquipmentTraffic selectByUniqueCode(String uniqueCode) throws BOException {
        // TODO Auto-generated method stub
        return null;
    }

    @Override
    public List<EquipmentTraffic> selectByExample(EquipmentTrafficExample example) throws BOException {
        return equipmentTrafficMapper.selectByExample(example);

    }

    @Override
    public long countByExample(EquipmentTrafficExample example) throws BOException {
        return equipmentTrafficMapper.countByExample(example);

    }

    @Override
    public PageResult findPage(PageRequest pageRequest, EquipmentTrafficExample example) throws BOException {
        int pageNum = pageRequest.getPage();
        int pageSize = pageRequest.getLimit();
        PageHelper.startPage(pageNum, pageSize);
        List<EquipmentTraffic> records = (List<EquipmentTraffic>) equipmentTrafficMapper.selectByExampleWithBLOBs(example);
        return PageUtils.getPageResult(pageRequest, new PageInfo<EquipmentTraffic>(records));

    }

    @Override
    public List<EquipmentTraffic> selectByExampleWithBLOBs(EquipmentTrafficExample example) throws BOException {
        // TODO Auto-generated method stub
        return equipmentTrafficMapper.selectByExampleWithBLOBs(example);
    }

    @Override
    public int updateByExampleWithBLOBs(EquipmentTraffic record, EquipmentTrafficExample example) throws BOException {
        // TODO Auto-generated method stub
        return 0;
    }

    @Override
    public int updateByPrimaryKeyWithBLOBs(EquipmentTraffic record) throws BOException {
        // TODO Auto-generated method stub
        return equipmentTrafficMapper.updateByPrimaryKeyWithBLOBs(record);
    }

    @Override
    public List<EquipmentTraffic> listShow(EquipmentTraffic equipmentTraffic) {
        // TODO Auto-generated method stub
        return equipmentTrafficMapper.listShow(equipmentTraffic);
    }

//    @Override
//    public PageResult findPage1(PageRequest pageRequest, EquipmentTraffic equipmentTraffic) throws BOException {
//        int pageNum = pageRequest.getPageNum();
//        int pageSize = pageRequest.getPageSize();
//        PageHelper.startPage(pageNum, pageSize);
//        List<EquipmentTraffic> records = equipmentTrafficMapper.listShow(equipmentTraffic);
//        return PageUtils.getPageResult(pageRequest, new PageInfo<EquipmentTraffic>(records));
//    }

    @Override
    public List<EquipmentTraffic> listS(EquipmentTraffic equipmentTraffic) {
        // TODO Auto-generated method stub
        return equipmentTrafficMapper.listS(equipmentTraffic);
    }

//    @Override
//    public PageResult findPage2(PageRequest pageRequest, EquipmentTraffic equipmentTraffic) throws BOException {
//        int pageNum = pageRequest.getPageNum();
//        int pageSize = pageRequest.getPageSize();
//        PageHelper.startPage(pageNum, pageSize);
//        List<EquipmentTraffic> records = equipmentTrafficMapper.listS(equipmentTraffic);
//        return PageUtils.getPageResult(pageRequest, new PageInfo<EquipmentTraffic>(records));
//    }

    @Override
    public long countByStaffidExample(EquipmentTrafficExample example) {
        return equipmentTrafficMapper.countByStaffidExample(example);
    }

    @Override
    public long countByIdcExample(EquipmentTrafficExample example) {
        return equipmentTrafficMapper.countByIdcExample(example);
    }

    @Override
    public List<EquipmentTraffic> selectByDate(EquipmentTraffic equipmentTraffic) {
        return equipmentTrafficMapper.selectByDate(equipmentTraffic);
    }

//    @Override
//    public PageResult findByDate(PageRequest pageRequest, EquipmentTraffic equipmentTraffic) throws BOException {
//        int pageNum = pageRequest.getPageNum();
//        int pageSize = pageRequest.getPageSize();
//        PageHelper.startPage(pageNum, pageSize);
//        List<EquipmentTraffic> records = equipmentTrafficMapper.selectByDate(equipmentTraffic);
//        return PageUtils.getPageResult(pageRequest, new PageInfo<EquipmentTraffic>(records));
//    }

    @Override
    public List<EquipmentTraffic> listSelectByDate(EquipmentTraffic equipmentTraffic) {
        return equipmentTrafficMapper.listSelectByDate(equipmentTraffic);
    }

//    @Override
//    public PageResult findByDateList(PageRequest pageRequest, EquipmentTraffic equipmentTraffic) throws BOException {
//        int pageNum = pageRequest.getPageNum();
//        int pageSize = pageRequest.getPageSize();
//        PageHelper.startPage(pageNum, pageSize);
//        List<EquipmentTraffic> records = equipmentTrafficMapper.listSelectByDate(equipmentTraffic);
//        return PageUtils.getPageResult(pageRequest, new PageInfo<EquipmentTraffic>(records));
//    }

    @Override
    public List<String> selectDistinctResults() {
        return equipmentTrafficMapper.selectDistinctResults();
    }

    @Override
    public List<EquipmentTrafficVo> listEquipmentTrafficVo(EquipmentTrafficVo equipmentTrafficVo) {
        return equipmentTrafficMapper.listEquipmentTrafficVo(equipmentTrafficVo);
    }

    @Override
    public Integer selectCount() {
        return equipmentTrafficMapper.count();
    }


}
